package com.sim.simserial.navigation.impl

import androidx.core.os.bundleOf
import androidx.navigation.NavController
import com.sim.serialport.library.seria.DataStore
import com.sim.simserial.R
import com.sim.simserial.navigation.MainNavigator
import com.sim.storage.GoodsBean
import javax.inject.Inject

class MainNavigatorImpl
@Inject
constructor(
    val dataStore: DataStore,
) : MainNavigator {
    private var activityNav: NavController? = null

    override fun bindNavController(activityNav: NavController) {
        this.activityNav = activityNav
    }

    override fun popBack() {
        this.activityNav?.popBackStack()
    }

    override fun toGoods() {
        activityNav?.navigate(R.id.toGoods)
    }

    override fun toFunctions() {
        activityNav?.navigate(R.id.toFunctions)
    }

    override fun toRequestAndResponse(type: String) {

        activityNav?.navigate(
            R.id.toRequestAndResponseFragment,
            bundleOf().apply {
                putString("typeString", type)
            },
        )
    }

    override fun toCoffeeDetail(model: GoodsBean) {
        activityNav?.navigate(R.id.toCoffeeDetail, bundleOf().apply { putParcelable("goods", model) })
    }

    override fun toOrderDetail(goods: List<GoodsBean>) {
        activityNav?.navigate(R.id.toOrderDetail, bundleOf().apply { putParcelableArrayList("goods", ArrayList(goods)) })
    }

    override fun toPrint() {
        activityNav?.navigate(R.id.toPrint)
    }
}
